/*
 * Copyright (c) 2024 Black Sesame Technologies
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _DAL_FASTDDS_CONFIG_MANAGER_HPP_
#define _DAL_FASTDDS_CONFIG_MANAGER_HPP_

#include <cstdlib>
#include <unistd.h>
#include <mutex>
#include <unordered_map>
#include "dal/config_loader.h"
#include "dal_fastdds/utils/log.hpp"

class ConfigManager {
public:
    enum ConfigType {
        CONFIG_TYPE_NOT_SET = 0,
        CONFIG_TYPE_SET_BY_ENV,
        CONFIG_TYPE_SET_BY_API,
    };

public:
    static ConfigManager* GetInstance();
    void setConfigType(ConfigType type);
    ConfigType getConfigType();
    bool loadConfigProfileByEnv();
    void setFastddsProfilePath(const std::string path);
    const std::string getFastddsProfilePath();
    void clearSetting();
    
private:
    ConfigManager() = default;
    ~ConfigManager() = default;
    ConfigManager(const ConfigManager&) = delete;
    ConfigManager& operator=(const ConfigManager&) = delete;

private:
    ConfigType config_type_ = ConfigType::CONFIG_TYPE_NOT_SET;
    std::string fastdds_profile_path_ = "";
};

#endif // _DAL_FASTDDS_CONFIG_MANAGER_HPP_